package com.mapper;

import com.pojo.Course;
import com.pojo.HuiDa;
import com.pojo.User;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

@Mapper
public interface HuiDaMapper  {
    @Select("SELECT hu.*,uh.h_id,uh.u_id FROM huida_chen hu JOIN user_hu uh on hu.id=uh.h_id join user_chen u on u.id=uh.u_id where u.id=#{id}")
    @Results({
            @Result(property = "id", column="id",id = true),
            @Result(property = "name",column = "name"),
            @Result(property = "text",column = "text"),
            @Result(property = "time",column = "time"),
            @Result(property = "userList",column = "hu.id",many = @Many(select = "com.mapper.HuiDaMapper.selectUser",fetchType = FetchType.LAZY))
    })
    List<HuiDa> selectAll(HuiDa huda);
    @Select("select u.id from user_chen u join user_hu uh on uh.u_id=u.id where uh.u_id=#{id};")
    List<User> selectUser(Integer id);
}
